package com.zhsh.generator.template.config;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 控制器模板生成的配置
 *
 * @author fengshuonan
 * @date 2017-05-07 22:12
 */
@Data
public class ControllerConfig {

    private ContextConfig contextConfig;

    private String controllerPathTemplate;
    /**
     * 包名称
     */
    private String packageName;

    /**
     * 所引入的包
     */
    private List<String> controllerImplImports;

    public void init() {
        ArrayList<String> imports = new ArrayList<>();
        imports.add("org.springframework.beans.factory.annotation.Autowired");
        imports.add("org.springframework.web.bind.annotation.GetMapping");
        imports.add("org.springframework.web.bind.annotation.PostMapping");
        imports.add("org.springframework.web.bind.annotation.RequestBody");
        imports.add("org.springframework.web.bind.annotation.RequestMapping");
        imports.add("org.springframework.web.bind.annotation.RestController");
        imports.add("com.jd.yao.common.base.vo.res.WebRes");
        imports.add("com.jd.yao.common.client.base.vo.ResPage");
        imports.add(contextConfig.getTemplateFilePrefix() + "." + contextConfig.getModuleName() + ".service." + contextConfig.getBizEnBigName() + "Service");
        Collections.sort(imports);
        this.controllerImplImports = imports;
        this.packageName = contextConfig.getTemplateFilePrefix() + "." + contextConfig.getModuleName() + ".controller";
        //this.controllerPathTemplate = "\\src\\main\\java\\com\\stylefeng\\guns\\modular\\" + contextConfig.getModuleName() + "\\controller\\{}Controller.java";
        this.controllerPathTemplate = "\\" + contextConfig.getTemplateFilePrefixWithLine() + "\\" + contextConfig.getModuleName() + "\\controller\\{}Controller.java";
    }

}
